/**********************************
 ***	Imports
 **********************************/
package fr.montreuil.wargame.controller;

import javax.annotation.Resource;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import fr.montreuil.wargame.domain.User;
import fr.montreuil.wargame.repository.UserRepository;

/**********************************
 *** 	@jgay
 *** 	@30 avr. 2012
 **********************************/
@Controller
@RequestMapping("/user")
public class UserController {
	
	@Resource
	private UserRepository users;
	
	@RequestMapping
	public String getHomePageUser(Model model) {
		User user = users.findByUsername(SecurityContextHolder.getContext().getAuthentication().getName());
		
		model.addAttribute("user", user);
		return "user";
	}
	
	

}
